
#include <stdio.h>
#include <stdlib.h>
#include "sysv_msgque.h"

int main()
{
	SysVMsgSndQueue sndQue(0xFFFF0001, 8192);
	SysVMsgRcvQueue rcvQue(0xFFFF0001, 8192);
	
	int len, ret = 0;
	for( int i = 0; i < 10; i++ )
	{
		sprintf( (char*)sndQue.getMsgAddr(), 
			"Msg%03d.", i+1 );
		sndQue.setMsgLen(256);
		
		ret = sndQue.sendMsg();
		
		ret = rcvQue.recvMsg();
		
		len = rcvQue.getMsgLen();
		
		printf( "msg_len = %d, Msg: %s\n", len, (char*)rcvQue.getMsgAddr() );
		
	}
	
	for( ; ; )
	{
		ret = rcvQue.recvMsg();
		if ( ret == -1 )
			break;

		len = rcvQue.getMsgLen();
		
		printf( "msg_len = %d, Msg: %s\n", len, (char*)rcvQue.getMsgAddr() );

	}

	return 0;
}
